var app = getApp()
var dialUtil = require("../../utils/dialUtil.js")
var util = require("../../utils/util.js")
var clerkModel = require("../../model/clerkModel.js")
var settingModel = require('../../model/settingModel.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    clerks: [],
    store: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.init();
  },
  init() {
    var that = this
    util.showLoading("加载中")
    settingModel.getStore(res => {
      if (res.status == 1) {
        util.failToast(res.msg)
        return
      }
      that.setData({
        store: res.data
      })
    })
    clerkModel.getClerks(res => {
      wx.hideLoading()
      if (res.status == 1) {
        util.failToast(res.msg)
        return
      }
      that.setData({
        clerks: res.data
      })
    })
  },
  //美容师详情页
  navToInfo(e) {
    app.data.clerk = this.data.clerks[e.currentTarget.id]
    wx.navigateTo({
      url: '../clerk_info/clerk_info',
    })
  },
  //快捷拨号
  bindDial() {
    var phone = this.data.store.phone
    dialUtil.dial(phone)
  }
})